[RISCV] Introduce RVI AME (standard, pre-ratification) backend support#22
[RISCV] Introduce RVI AME (standard, pre-ratification) backend support#22vismaysur wants to merge 10 commits into
Conversation
|
Hello @vismaysur 👋 Thank you for submitting a Pull Request (PR) to the LLVM Project. Since this is your first PR, here are a few useful links covering our main contribution policies and review practices.
Please reply to this message to confirm that you have read these policies, especially the LLVM AI Tool Use Policy, and that any AI tool usage has been noted in the PR description. Frequently asked questionsHow do I add reviewers? This PR will be automatically labeled, and the relevant teams will be notified. For some parts of the project, reviewers may also be added automatically. You can also add reviewers manually using the Reviewers section on this page. If you cannot use that section, it is probably because you do not have write permissions for the repository. In that case, you can request a review by tagging reviewers in a comment using What if there are no comments? If you have not received any comments on your PR after a week, you can request a review by pinging the PR with a comment such as “Ping”. The common courtesy ping rate is once a week. Please remember that you are asking for volunteer time from other developers. Are any special GitHub settings required to contribute to LLVM? We only require contributors to have a public email address associated with their GitHub commits, see this section of LLVM Developer Policy for details. If you have questions, feel free to leave a comment on this PR, or ask on LLVM Discord or LLVM Discourse. Thank you, |
|
A few important observations / notes:
Just a detail to keep note of: if a stride operand is later added to the spec, we will not need to repack data in memory into tiles. |
12d2b78 to
36036f7
Compare
e7c4297 to
8d7801d
Compare
b1e3edf to
5c844e7
Compare
5c844e7 to
c28b72e
Compare
b5dac9e to
a4a3978
Compare
a4a3978 to
2cc830c
Compare
Good catch. We will keep our design aligned with the RVI specification and make the corresponding changes if the specification is updated. |
|
Please rebase the PR. I will start the review today. |
2cc830c to
b9c7652
Compare
|
Note: BOSCAME backend seems to instruction select LLVM IR to pseudo instructions (with immediate operands) which are then directly printed as asm, with no path (as i understand it) to MCInstr encodings / .o output. it has real instruction encodings but these are only reachable from .s or .o inputs, not from LLVM IR (please clarify if my understanding is incorrect). Since M/Acc indices are already assigned by MLIR before they reach LLVM, so encoding them as immediates (rather than encoding register class operands) lets ISel lower straight to the real, bit-encoded instruction. I took a slightly different path in this backend of omitting the pseudo instructions altogether, instead encoding real instructions with immediate operands, enabling a single path from LLVM IR -> MCInstr with real encodings -> both .o and .s outputs. |
b9c7652 to
1cba266
Compare
1cba266 to
9cd2449
Compare
There was a problem hiding this comment.
@vismaysur, I listed the problems I found.
cc @Yranger, there are some changes regarding BOSC AME that need to be reviewed.
| static const unsigned Regs[] = {RISCV::BOSCAMETR0, RISCV::BOSCAMETR1, | ||
| RISCV::BOSCAMETR2, RISCV::BOSCAMETR3, | ||
| RISCV::BOSCAMETR4, RISCV::BOSCAMETR5, | ||
| RISCV::BOSCAMETR4, RISCV::BOSCAMETR7}; |
There was a problem hiding this comment.
RISCV::BOSCAMETR4 -> RISCV::BOSCAMETR6
| @@ -0,0 +1,585 @@ | |||
| //===- RISCVInstrInfoZtt.td - 'Ztt' ----------*- tablegen -*-===// | |||
| bits<5> xs1; | ||
| bits<2> ad; | ||
|
|
||
| let Inst{19 - 15} = xs1; |
| // Moves | ||
| def : Pat<(int_riscv_ztt_mmov_a_m timm:$md, timm:$acc), (ZTT_MMOV_A_M timm:$md, timm:$acc)>; | ||
| def : Pat<(int_riscv_ztt_mmov_m_m timm:$md, timm:$ms), (ZTT_MMOV_M_M timm:$md, timm:$ms)>; | ||
| def : Pat<(int_riscv_ztt_mshift_ew timm:$md, timm:$ms1, timm:$imm), |
There was a problem hiding this comment.
llvm.riscv.ztt.mshift.m1 and llvm.riscv.ztt.mshift.p1 are declared in llvm/include/llvm/IR/IntrinsicsRISCVStdExtZtt.td, but there are no corresponding ISel patterns in this file.
According to the AME specification, mshift.m1 and mshift.p1 are aliases of mshift.ew with immediate values -1 and 1, respectively. Please either:
- add lowering patterns that select them to
ZTT_MSHIFT_EW
or:
- remove the two LLVM intrinsics and model them only as assembler aliases using
InstAlias.
The second option may be preferable because these are aliases rather than independent instructions.
Please also add CodeGen tests covering both intrinsics if they remain exposed through LLVM IR.
|
@vismaysur Please use clang-format to format all files and check the license header formatting. |
This PR adds initial RISC-V AME backend support.
Tasks/Deliverables:
AME_NUM_M_REGSandAME_NUM_ACC_REGS).ll->.sand.ll->.o) and llvm-mc (.s->.o).Closes #21